import os

def generate_video_command(format, resolution, size, duration):
    filename = f'test_video_{resolution}_{size}MB_{duration}s.{format}'
    target_size = size * 1024 * 1024  # 转换为字节

    command = (
        f'ffmpeg -f lavfi -i color=c=blue:s={resolution}:d={duration} '
        f'-vf "drawtext=text=\'Test Video\':fontcolor=white:fontsize=30:x=(w-tw)/2:y=(h-th)/2" '
        f'-b:v {int(target_size / duration)} -y H:\\zhangna\\Videos\\{filename}\n'
    )
    return command

def main():
    formats = ['mp4', 'avi', 'mkv', 'mov', 'flv', 'wmv']
    resolutions = ['640x480', '1280x720', '1920x1080', '3840x2160']
    sizes = [1, 1024, 2048, 4096, 8192, 16384]
    durations = [1, 10, 30, 60, 300, 600, 3600]
    i=0
    with open('generate_videos.bat', 'w', encoding='utf-8') as f:
        for format in formats:
            for resolution in resolutions:
                for size in sizes:
                    for duration in durations:
                        if (size / duration) <= (2 ** 20):  # 保证大小和时长的比例不过高
                            print(f'Generating {format} video with resolution {resolution}, size {size}MB, duration {duration}s')
                            command = generate_video_command(format, resolution, size, duration)
                            f.write(command)
                            i+=1
                            if i==4:
                                return
if __name__ == '__main__':
    main()
